#include "../3dparty/gtest-support.h"
#include "../include/string.h"

#include <string>

TEST( SStringTestConcatCase, SStringTest )
{
    SString str1;
    SString str2;
    SString str3;
    SString str4;

    EXPECT_EQ( OK, CreateSString( &str1, "Hello ", strlen( "Hello " ) ) );
    EXPECT_EQ( OK, CreateSString( &str2, "World!", strlen( "World!" ) ) );
    EXPECT_EQ( OK, CreateSString( &str4, "Hello World!", strlen( "Hello World!" ) ) );
    EXPECT_EQ( TRUE, ConcatSString( &str3, str1, str2 ) );
    EXPECT_EQ( TRUE, CmpSString( &str3, &str4 ) );
}

TEST( SStringTestSubStrCase, SStringTest )
{
    SString str1;
    SString str2;
    SString substr;

    EXPECT_EQ( OK, CreateSString( &str1, "Hello World!", strlen( "Hello World!" ) ) );
    EXPECT_EQ( OK, CreateSString( &str2, "World", strlen( "World" ) ) );
    EXPECT_EQ( OK, SubString( &substr, str1, 7, 5 ) );
    EXPECT_EQ( TRUE, CmpSString( &str2, &substr ) );
}
/*
TEST( SStringTestKMPCase, SStringTest )
{
    SString str1;
    SString str2;
    SString substr;

    EXPECT_EQ( OK, CreateSString( &str1, "abddfbcaabaabcdg!", strlen( "abddfbcaabaabcdg!" ) ) );
    EXPECT_EQ( OK, CreateSString( &str2, "abaabc", strlen( "abaabc" ) ) );
    EXPECT_EQ( 9, KMP( &str1, &str2, 0 ) );
    EXPECT_EQ( TRUE, CmpSString( &str2, &substr ) );
}*/

TEST( KMPTestCase, SStringTest )
{
    const char *pSrc = "abddfbcaabaabcdg";
    const char *pSchema = "abaabc";
    EXPECT_EQ( 8, kmp( pSrc, strlen( pSrc ), pSchema, strlen( pSchema ), 0 ) );
}

